package JVM;

public class heapTest {
    public void hahaah(){
        byte[] test=new byte[1024*1024];
        hahaah();
    }

    static Object o1=new Object();
    static Object o2=new Object();
    public static void deadlock1() throws InterruptedException {
        synchronized (o1){
            Thread.sleep(500);
            synchronized (o2){

            }
        }
    }

    public static void deadlock2(){
        synchronized (o2){
            synchronized (o1){

            }
        }
    }

    public static void main(String[] args) {
        //new heapTest().hahaah();
        new Thread(()->{
            try {
                deadlock1();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }).start();
        new Thread(()->{
            deadlock2();
        }).start();
    }


}
